var wfloat 	= new WFloat('wfloat');
var s_id	= 0;
function micro_right(obj,m,pm)
{
	var x = wfloat.get_left(obj);
	var y = wfloat.get_top(obj);
	var str = "<table>"
	if((pm & 1) != 1)
		readonly = " disabled='disabled' ";
	else
		readonly = "";
	str		+= "<tr><td width=\"50\">增加</td><td width=\"50\" style=\"text-align:right\"><input type=\"checkbox\" name=\"add\" value=\"1\" "+readonly+"></td></tr>";
	if((pm & 2) != 2)
		readonly = " disabled='disabled' ";
	else
		readonly = "";
	str		+= "<tr><td width=\"50\">修改</td><td width=\"50\" style=\"text-align:right\"><input type=\"checkbox\" name=\"edit\" value=\"2\" "+readonly+"></td></tr>";
	if((pm & 4) != 4)
		readonly = " disabled='disabled' ";
	else
		readonly = "";
	str		+= "<tr><td width=\"50\">删除</td><td width=\"50\" style=\"text-align:right\"><input type=\"checkbox\" name=\"del\" value=\"4\" "+readonly+"></td></tr>";
	if((pm & 8) != 8)
		readonly = " disabled='disabled' ";
	else
		readonly = "";
	str		+= "<tr><td width=\"50\">审核</td><td width=\"50\" style=\"text-align:right\"><input type=\"checkbox\" name=\"auditing\" value=\"8\" "+readonly+"></td></tr>";
	str		+= "<tr><td colspan=\"2\" style=\"text-align:center;\" id=\"micro_right\"></td></tr>";
	str 	+= "</table>";
	wfloat.msg_s('<b>微权限</b>', str, 140, 120, x, y);
	var obj = wfloat.getID("micro_right")
	var btn1 = document.createElement("button");
	btn1.value = " 保存 ";
	btn1.className = "button";
	btn1.attachEvent("onclick",micro_save);
	obj.appendChild(btn1);
	var span = document.createElement("span");
	span.innerHTML = "&nbsp;&nbsp;";
	obj.appendChild(span);
	var btn2 = document.createElement("button");
	btn2.value = " 取消 ";
	btn2.className = "button";
	btn2.attachEvent("onclick",micro_cancel);
	obj.appendChild(btn2);
	var val = wfloat.getID("fun_"+m);
	s_id	= m;
	chk	= wfloat.getID("add");
	if((val.value & 1) == 1)
		chk.checked = true;
	else
		chk.checked = false;
	chk	= wfloat.getID("edit");
	if((val.value & 2) == 2)
		chk.checked = true;
	else
		chk.checked = false;
	chk	= wfloat.getID("del");
	if((val.value & 4) == 4)
		chk.checked = true;
	else
		chk.checked = false;
	chk	= wfloat.getID("auditing");
	if((val.value & 8) == 8)
		chk.checked = true;
	else
		chk.checked = false;
}
function micro_save()
{
	val = 0;
	var chk	= wfloat.getID("add");
	if(chk.checked && !chk.disabled)
		val += 1;
	chk	= wfloat.getID("edit");
	if(chk.checked && !chk.disabled)
		val += 2;
	chk	= wfloat.getID("del");
	if(chk.checked && !chk.disabled)
		val += 4;
	chk	= wfloat.getID("auditing");
	if(chk.checked && !chk.disabled)
		val += 8;
	var obj = wfloat.getID("fun_"+s_id);
	obj.value = val;
	wfloat.msg_h();
}
function micro_cancel()
{
	wfloat.msg_h();
}
function TreeDisplay(obj)
{
	try
	{
		var li = obj.parentElement;
		var ul = li.getElementsByTagName("UL")[0];
		if(ul.style.display=="none")
			ul.style.display="block";
		else
			ul.style.display="none";
	}
	catch(e)
	{
		;
	}
}
function selectfun(obj)
{
	try
	{	
		var li = obj.parentElement;
		//获取所有的checkbox
		var chk = li.getElementsByTagName("INPUT");
		var len = chk.length;
		for(i=1;i<len;i++)
			chk[i].checked = chk[0].checked;
		if(chk[0].checked==false)
			pcancel(li);
		else
			pcheck(li);
		
	}
	catch(e)
	{
		//alert(e.description);
	}
}
function findobj(code)
{
	try
	{
		obj = document.getElementsByTagName("INPUT");
		for(i=0;i<obj.length;i++)
			if(obj[i].value==code)
				return obj[i];
		return null;
	}
	catch(e)
	{
		//alert(e.description);
	}
}
function pcheck(obj)
{
	try
	{
		var ul = obj.parentElement;
		var li = ul.parentElement;
		if(li.tagName == "LI")
		{
			var chk = li.getElementsByTagName("INPUT");
			chk[0].checked = true;
		}
	}
	catch(e)
	{
		;//alert();
	}
}
function pcancel(obj)
{
	try
	{
		var ul = obj.parentElement;
		var chk = ul.getElementsByTagName("INPUT");
		//检查所有的checkbox是否都没有选

		var len = chk.length;
		for(i=0;i<len;i++)
		{
			if(chk[i].checked)
				return;
		}
		//获取上一层的li
		li = ul.parentElement;
		if(li.tagName == "LI")
		{
			chk = li.getElementsByTagName("INPUT");
			chk[0].checked = false;
			pcancel(li);
		}
	}
	catch(e)
	{
		//alert(e.description);//alert();
	}
	
}
function CheckForm(){
	
}